<?php

if(isset($_POST['request_add'])){

	$params = array(
		'tid'	=> 1,//empty(trim($_POST['question_type'])) ? 1 : trim($_POST['question_type']),
		'name'	=> trim($_POST['question_name']),
		'level'	=> empty(trim($_POST['question_level'])) ? 1 : trim($_POST['question_level']),
		'sid'	=> empty(trim($_POST['question_service'])) ? 1 : trim($_POST['question_service'])
	);
	
	if($params['name']){
		
		$params['name'] = preg_replace("/[\/\'\"]/","",$params['name']);show($params['name']);
		$db = new models($host,$user,$pass,$db_name);
		$db->select("id");
		$db->where("name='".$params['name']."'");
		$question = $db->get_data("question");
		
		if(!$question){
			$db->insert("question",$params);
			redirect("$home_url/admin/questions/?notice=success");
		}else
			redirect("$home_url/admin/questions/?notice=duplicate");
		
	}else{
		redirect("$home_url/admin/questions/?notice=error");
	}
}